﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JSON;
using Facebook_Graph_Toolkit.FacebookObjects;

namespace Facebook_Graph_Toolkit.GraphApi {
    /// <summary>
    /// A link shared on a user's wall
    /// </summary>
    [Serializable]
    public class Link : GraphApiObject{
        internal Link(JsonObject JO) : base(JO) {
        }
        /// <summary>
        /// The link ID
        /// </summary>
        public string ID { get { return (string)data["id"]; } }
        /// <summary>
        /// The user that created the link
        /// </summary>
        public NameIDPair Owner { get { return new NameIDPair((JsonObject)data["from"]); } }
        /// <summary>
        /// The URL that was shared
        /// </summary>
        public string SharedURL { get { return (string)data["link"]; } }
        /// <summary>
        /// The name of the link
        /// </summary>
        public string Name { get { return (string)data["name"]; } }
        /// <summary>
        /// The caption of the link (appears beneath the link name)
        /// </summary>
        public string Caption { get { return (string)data["caption"]; } }
        /// <summary>
        /// A description of the link (appears beneath the link caption)
        /// </summary>
        public string Description { get { return (string)data["description"]; } }
        /// <summary>
        /// A URL to the link icon that Facebook displays in the news feed
        /// </summary>
        public string IconUrl { get { return (string)data["icon"]; } }
        /// <summary>
        /// A URL to the thumbnail image used in the link post
        /// </summary>
        public string ThumbnailUrl { get { return (string)data["picture"]; } }
        /// <summary>
        /// The optional message from the user about this link
        /// </summary>
        public string Message { get { return (string)data["message"]; } }
        /// <summary>
        /// The time the message was published
        /// </summary>
        public DateTime CreatedTime {
            get {
                return Helpers.Common.RFC3339ToDateTime((string)data["created_time"]);
            }
        }
    }
}
